package com.ruoyi.st.service.impl;

import com.ruoyi.st.domain.StAddrDetail;
import com.ruoyi.st.mapper.StAddrDetailMapper;
import com.ruoyi.st.service.IStAddrDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 地址详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@Service
public class StAddrDetailServiceImpl implements IStAddrDetailService 
{
    @Autowired
    private StAddrDetailMapper stAddrDetailMapper;

    /**
     * 查询地址详情
     * 
     * @param id 地址详情主键
     * @return 地址详情
     */
    @Override
    public StAddrDetail selectStAddrDetailById(Long id)
    {
        return stAddrDetailMapper.selectStAddrDetailById(id);
    }

    /**
     * 查询地址详情列表
     * 
     * @param stAddrDetail 地址详情
     * @return 地址详情
     */
    @Override
    public List<StAddrDetail> selectStAddrDetailList(StAddrDetail stAddrDetail)
    {
        return stAddrDetailMapper.selectStAddrDetailList(stAddrDetail);
    }

    @Override
    public List<StAddrDetail> selectStAddrDetailByUserId(Long userId) {
        List<StAddrDetail> list = stAddrDetailMapper.selectStAddrDetailByUserId(userId);
        return list;
    }

    /**
     * 新增地址详情
     * 
     * @param stAddrDetail 地址详情
     * @return 结果
     */
    @Override
    public int insertStAddrDetail(StAddrDetail stAddrDetail)
    {
       stAddrDetail.setCreatedAt(new Date());
        return stAddrDetailMapper.insertStAddrDetail(stAddrDetail);
    }

    /**
     * 修改地址详情
     * 
     * @param stAddrDetail 地址详情
     * @return 结果
     */
    @Override
    public int updateStAddrDetail(StAddrDetail stAddrDetail)
    {
        stAddrDetail.setUpdatedAt(new Date());
        return stAddrDetailMapper.updateStAddrDetail(stAddrDetail);
    }

    /**
     * 批量删除地址详情
     * 
     * @param ids 需要删除的地址详情主键
     * @return 结果
     */
    @Override
    public int deleteStAddrDetailByIds(Long[] ids)
    {
        return stAddrDetailMapper.deleteStAddrDetailByIds(ids);
    }

    /**
     * 删除地址详情信息
     * 
     * @param id 地址详情主键
     * @return 结果
     */
    @Override
    public int deleteStAddrDetailById(Long id)
    {

        return stAddrDetailMapper.deleteStAddrDetailById(id);
    }
}
